package com.cincc.cinccimdemo.model;

import android.text.TextUtils;
import android.util.Log;

import com.cincc.im.model.enums.SendStatus;

import org.json.JSONObject;

public class MessageInfoUI {
    private MessageInfo messageInfo;
    private SendStatus messageStatus;
    private boolean isPlaying;

    private boolean isPlayed = false;

    public MessageInfoUI(MessageInfo imMessage) {
        this.messageInfo = imMessage;
        this.messageStatus = imMessage.sendStatus;
        String fileAttrs = imMessage.fileAttrs;
        if (!TextUtils.isEmpty(fileAttrs)) {
            try {
                JSONObject j = new JSONObject(fileAttrs);
                this.isPlayed = j.optBoolean("played", false);
            } catch (Exception e) {
                Log.e("MessageInfoUI", "MessageInfoUI: " + e.getMessage());
            }
        }
    }

    public MessageInfo getMessageInfo() {
        return messageInfo;
    }

    public void setMessageInfo(MessageInfo messageInfo) {
        this.messageInfo = messageInfo;
    }

    public SendStatus getMessageStatus() {
        return messageStatus;
    }

    public void setMessageStatus(SendStatus messageStatus) {
        this.messageStatus = messageStatus;
    }

    public boolean isPlaying() {
        return isPlaying;
    }

    public void setPlaying(boolean playing) {
        isPlaying = playing;
    }

    public String getRemoteMsgId() {
        return messageInfo.messageId;
    }

    public void setRemoteMsgId(String remoteMsgId) {
        this.messageInfo.messageId = remoteMsgId;
    }

    public boolean isPlayed() {
        return isPlayed;
    }

    public void setPlayed(boolean played) {
        isPlayed = played;
    }
}
